package com.galo.service.service;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 无线开关
 */
@Component
public class WirelessSwitchService {

    @Autowired
    private MqttGateway gateway;

    /**
     * 无线开关控制接口
     * @param devsn
     * @param sta
     */
    @Async("taskExecutor")
    public void control(String devsn,String sta){
        Map map = new LinkedHashMap();
        map.put("type","switch");
        map.put("action","set");
        map.put("devsn",devsn);
        map.put("sta",sta);
        gateway.sendToMqtt("galo/device/control/switch",1, JSON.toJSONString(map));
    }

}
